package org.idea.qiyu.framework.web.config;

import org.idea.qiyu.framework.web.interceptor.QiyuInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author linhao
 * @Date created in 8:23 上午 2021/9/6
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Bean
    public QiyuInterceptor qiyuInterceptor(){
        return new QiyuInterceptor();
    }

    @Bean
    public QiyuInitializingAdvice qiyuInitializingAdvice(){
        return new QiyuInitializingAdvice();
    }

    //注册拦截器

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(qiyuInterceptor()).addPathPatterns("/**").excludePathPatterns("/error");
    }
}
